package com.wk.note;

/**
 * @author WK
 * @version 1.0
 * @date 2024-07-11 19:50
 */
//package com.example.conceptnotebookjava;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class H2Database {

    public static final String DB_URL = "jdbc:h2:~/concept_notebook";
    public static final String DB_USERNAME = "sa";
    public static final String DB_PASSWORD = "";

    public static void createTables() {
        try (Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
             Statement stmt = conn.createStatement()) {

            // Create notes table
            String createNotesTableSQL = "CREATE TABLE IF NOT EXISTS notes (" +
                    "id INT AUTO_INCREMENT PRIMARY KEY, " +
                    "filename VARCHAR(255) NOT NULL, " +
                    "tags VARCHAR(255) NOT NULL)";
            stmt.executeUpdate(createNotesTableSQL);

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        createTables();
    }
}
